#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
    int data;
    struct node* next;
}LNode;

void SListPushBack(LNode** phead,int x)
{
    LNode* newnode=(LNode*)malloc(sizeof(LNode));
    newnode->data=x;
    newnode->next=NULL;
    if(*phead==NULL)
    {
        *phead=newnode;
    }
    else
    {
        LNode* tail=*phead;
        while(tail->next!=NULL)
        {
            tail=tail->next;
        }
        tail->next=newnode;
    }
}
void SListErase(LNode**phead,int y)
{
    if((*phead)->data==y)
    {
        *phead=(*phead)->next;
    }
    LNode* cur=*phead;
    LNode* pre=cur;
    while(cur!=NULL)
    {
        while(cur->data==y)
        {
            pre->next=cur->next;
            cur=cur->next;
        }
        pre=cur;
        cur=cur->next;
    }
}
int main()
{
    int n,x;
    LNode* plist=NULL;
    while(scanf("%d",&n)!=EOF)
    {
         LNode* plist=NULL;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            SListPushBack(&plist,x);
        }
        int y;
        scanf("%d",&y);
        SListErase(&plist,y);
        LNode* cur=plist;
        while(cur!=NULL)
        {
            printf("%d ",cur->data);
            cur=cur->next;
        }
    }
    return 0;
}

